package cz.muni.fi.hauntedhouses.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Temporal;

/**
 *
 * @author Vanda Cabanová, 325371
 */
@Entity
public class House implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    /**
     * Name of the house of length 20 characters. Name is supposed to differ the houses in the game.
     */
    @Column(columnDefinition="VARCHAR(20)")
    private String name;
    
    /**
     * Address of the house, can be 40 characters long.
     */
    @Column(columnDefinition="VARCHAR(40)")
    private String address;
    
    /**
     * Date the house is haunted since.
     */
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date hauntedSince;
    
    /**
     * History of the house. Can be 200 characters long.
     */
    @Column(columnDefinition="VARCHAR(200)")
    private String history;
           
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Date getHauntedSince() {
        return hauntedSince;
    }

    public void setHauntedSince(Date hauntedSince) {
        this.hauntedSince = hauntedSince;
    }

    public String getHistory() {
        return history;
    }

    public void setHistory(String history) {
        this.history = history;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {        
        if (!(object instanceof House)) {
            return false;
        }
        House other = (House) object;
        if ((this.id == null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "House [ id=" + id + ", name=" + name + ", address=" + address + ", haunted since " + hauntedSince + "\n history:" + history + " ]";
        
    }
    
}
